package LineCode.Recruit2017.网易;

import java.util.Scanner;

/**
 * 两种苹果袋，6、8，恰好需要n(1 ≤ n ≤ 100)个苹果，没有则-1
 *
 * 1.动态规划
 * 2.贪心（先都为8，不满足换6）
 * 3.数学分析 (n-1)/8+1  (n>=16时)
 */
public class 买苹果 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            Integer n = sc.nextInt();
            int f[] = new int[n+8];
            f[6] = f[8] = 1;
            for (int i = 6; i < n; i += 2) {
                if (f[i] != 0) {
                    if (f[i + 6] == 0 || f[i + 6] > f[i] + 1) {
                        f[i + 6] = f[i] + 1;
                    }
                    if (f[i + 8] == 0 || f[i + 8] > f[i] + 1) {
                        f[i + 8] = f[i] + 1;
                    }
                }
            }
            if (f[n] == 0) {
                System.out.println(-1);
            } else {
                System.out.println(f[n]);
            }
        }
    }
}
